package com.huishen.edrivenew.widget;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

/**
 * 日历fragment适配器
 *
 */
public class CalendarPagerAdapter extends FragmentStatePagerAdapter {
    
    
    private String beginDate, endDate; // 日历控件的可选区间
    private int[] colors = null;
    private boolean isSection = false;

    
    // private CalendarResult fragment ;
    public CalendarPagerAdapter(FragmentManager fm) {
        super(fm);
    }
    

    /**
     * 设置可选区间
     */
    public void setSection(String beginDate, String endDate, int[] colors) {
        this.isSection = true;
        
        this.beginDate = beginDate;
        this.endDate = endDate;
        this.colors = colors;
    }
    

    @Override
    public Fragment getItem(int position) {
        CalendarPagerFragment fragment = null;
        
//        if (this.isSection) {
//            fragment = CalendarPagerFragment.create(position, this.beginDate, this.endDate,
//                            this.colors);
//            return fragment;
//        }
        fragment = CalendarPagerFragment.create(position);
        return fragment;
    }

    
    /**
     * 需生成的所有月份
     */
    @Override
    public int getCount() {
//        return CalendarUtil.getAllMonth();
        return 1;
    }

}
